--important, reminder, Digit ! This is stage4 type, not stage 3 type.
--  therefor, mind your pastes from type 3 to type 4 need the " h" taken out of equations
--also
--  check daskherbserchtest.hs to see how far you got towards implementing faux search.

import Data.List
import Network
import System.IO
import System.Exit
import Control.Arrow
import Control.Monad.Reader
import Control.Exception
import Text.Printf
import System.Random  -- import random, it said, surely they meant import Random, trying System.Random
       
--server = "irc.freenode.org"
server = "irc.libera.chat"
port   = 6667
--chan   = "##bedrock-ganja"
--chan   = "##bedrock-treehouse"
--chan   = "##gentoo-herb"
chan   = "#gentoo-weed"
--chan   = "##tokingaspies"
--chan   = "#gentoo-weed ##bedrock-treehouse ##tokingaspies" -- this launched, but still only in #gentoo-weed
--chan   = "#gentoo-weed, ##bedrock-treehouse, ##tokingaspies" -- -- lol!  it just returns ##bedrock-treehouse for all commands.
--chan   = "#gentoo-weed" "##bedrock-treehouse" "##tokingaspies"  -- nice try, but no, not how to join more than 1 chan
--chana  = "##bedrock-treehouse"   -- nice try, but no, not how to join more than 1 chan
--chanb  = "##toking-aspies"  -- nice try, but no, not how to join more than 1 chan
--chan   = "##tokingaspies"
--chan   = "#akashicwhatever"
--chan   = "##bedrock-chat"
--chan   = "#muhcows"
--chan   = "#cultivators"
nick   = "daskherb"
 
-- The 'Net' monad, a wrapper over IO, carrying the bot's immutable state.
type Net = ReaderT Bot IO
data Bot = Bot { socket :: Handle }
 
-- Set up actions to run on start and end, and run the main loop
main :: IO ()
main = bracket connect disconnect loop
  where
    disconnect = hClose . socket
    loop st    = runReaderT run st
 
-- Connect to the server and return the initial bot state
connect :: IO Bot
connect = notify $ do
    h <- connectTo server (PortNumber (fromIntegral port))
    hSetBuffering h NoBuffering
    return (Bot h)
  where
    notify a = bracket_
        (printf "Connecting to %s ... " server >> hFlush stdout)
        (putStrLn "done.")
        a
 
-- We're in the Net monad now, so we've connected successfully
-- Join a channel, and start processing commands
run :: Net ()
run = do
    write "NICK" nick
    write "USER" (nick++" 0 * :DigitsStonerBot")
    write "JOIN" chan
--    write h "JOIN" Chana  -- nice try, but no, not how to join more than 1 chan
--    write h "JOIN" Chanb  -- nice try, but no, not how to join more than 1 chan
    asks socket >>= listen
 
-- Process each line from the server
listen :: Handle -> Net ()
listen h = forever $ do
    s <- init `fmap` io (hGetLine h)
    io (putStrLn s)
    if ping s then pong s else eval (clean s)
  where
    forever a = a >> forever a
    clean     = drop 1 . dropWhile (/= ':') . drop 1
    ping x    = "PING :" `isPrefixOf` x
    pong x    = write "PONG" (':' : drop 6 x)
    
--let ecumenical = ["yes","that would be an ecumenical matter."]
--let ecumenical = [("yes"),("that would be an ecumenical matter.")]
--ecumenical = [("yes"),("that would be an ecumenical matter.")]
-- oh oh array! lets try that!
--ecumenical = array (1, 3) [(1, "yes"),(2, "that would be an ecumenical matter."),(3, "drink!")]

-- Dispatch a command
eval :: String -> Net ()
eval     "!quit"               = write "QUIT" ":Exiting" >> io (exitWith ExitSuccess)
eval x | "!id " `isPrefixOf` x = privmsg (drop 4 x)
eval "tryme" = privmsg "this will never work"
--eval h x | Just x <- stripPrefix "!id " x = privmsg h x
--eval h (stripPrefix "!id " -> Just x) = privmsg h x
--eval x | "!id " `isPrefixOf` x = privmsg (drop 4 x)
-- -- !search, based on !id/!say^... oops, made this then realised i already made !seek and !search
eval x | "!research " `isPrefixOf` x = privmsg ("https://lmddgtfy.net/?q=" ++ (drop 10 x))
eval x | "!seek " `isPrefixOf` x = privmsg ("well you would want to search for " ++ (drop 6 x) ++ " wouldnt you.") -- JOY (this is the winner, we can delete the rest... once you dont want them around any longer to see how you incrementally got there today.
eval x | "bakunin" `isInfixOf` x = privmsg "Freedom without socialism is privilege and injustice.  Socialism without freedom is slavery and brutality.  -- Bakunin"
--single
--"https://duckduckgo.com/?q=words" "https://lmddgtfy.net/?q=words"
--[2018-07-15 20:28:21] <el3> string.replace(" ", "%20")
-- izgud
--eval x | "!search " `isPrefixOf` x = privmsg ("https://lmddgtfy.net/?q=" ++ (drop 8 x) ++ " ?  :)") 
--multiple
-- eval x | "!search " `isPrefixOf` x = privmsg ("https://lmddgtfy.net/?q=" ++ (drop 8 x) ++ " though i caution you, these are not the droids you're looking for") 
--https://lmsptfy.com/?q=overton%20window
-- izgud  (i think... testing...)
eval x | "!search " `isPrefixOf` x = privmsg ("https://lmsptfy.com/?q=" ++ (drop 8 x) ++ " ?  :)") 

-- -- dev-wishlist, ability to say nick of ye who called forth a command.   ... not just x for whatever else was said.   ... did i ever find that yet?

--eval x | "!dab " `isPrefixOf` x = privmsg ("FWOOM goes the ganja's gold, " ++ (drop 4 x) ++ "! ganja dabba doo!") 
--eval "!dab" = privmsg ("FWOOM goes the ganja's gold! ganja dabba doo!") 
--eval x | "!dab straw" `isPrefixOf` x = privmsg ("FWOOM goes the ganja's gold, " ++ (drop 9 x) ++ "! ganja dabba doo!")
--eval "!dab straw" = privmsg ("FWOOM goes the ganja's gold! ganja dabba doo!") 

-- !blaze !fwoom
eval x | "!blaze " `isPrefixOf` x = privmsg ("FWOOM go the ganja trees, " ++ (drop 6 x) ++ "! setting the world alite, the good way.") 

-- !fwoom !blaze
eval x | "!fwoom " `isPrefixOf` x = privmsg ("Blazing ganja trees, " ++ (drop 7 x) ++ "! set the world alite, the good way.") 
-- !stone
eval x | "!stone " `isPrefixOf` x = privmsg ("ganja stones " ++ (drop 7 x) ++ " to... well, stoned!")
-- add wim hof stuff.  !hof n such
--
eval x | "!pass " `isPrefixOf` x = privmsg ("Puff Puff Pass, " ++ (drop 6 x) ++ "! You're fucking up the rotation.") -- test remake of weedykins' !toke
--eval x | "?!" `isSuffixOf` x = privmsg ("I dont know (or maybe I do), and cant (or wont) tell you.")
--eval "!toke daskherb" = privmsg "dont pass to me.  i dont have the lungs for it." -- got that elsewhere... 
--
-- this is to replace weedykins' !toke, when weedykins is absent
--eval x | "!toke " `isPrefixOf` x = privmsg ("Puff Puff Pass to " ++ (drop 6 x) ++ "! ^__^ ") -- test remake of weedykins' !toke
eval "!toke" = privmsg "toke the pain away!"
--eval x | "?!" `isSuffixOf` x = privmsg ("I dont know (or maybe I do), and cant (or wont) tell you.")
-----------------------------
-----------------------------
----- fatherjackbot dev -----
--teehee.  trained jack feature development happening here.
-- level ONEs
-- now get these two under the same "?"
--eval x | "?" `isSuffixOf` x = privmsg ("yes")
--eval x | "!?" `isSuffixOf` x = privmsg ("that would be an ecumenical matter.")
-- level TWOs (as developed in daskjack.hs (and then fatherjackbot.hs))
---------- works
--eval x | "?" `isSuffixOf` x = privmsg (if x == "?" then "that would be an ecumenical matter" else "yes") -- works  :)  use me!  use me!
-- the less spammy silenced(tedprefixed) version of level two working. *
--  *
--
--[2018-08- 1 02:02:00] <+Digit> i thought i covered that with my volunteered info, why am i being interogated?
--[2018-08- 1 02:02:01] <daskherb> yes
--[2018-08- 1 02:02:35] <+Digit> oh, daskherb i thought i told you to stop answering any question with a yes?
--[2018-08- 1 02:49:47] <+Digit> oh, i see, the isSufficOf is in effect, but the if x == "ted?" on the right of the equation still elsing so any~  yeah, just gonna comment that out until i get it right.  ... ideally with a live toggle to stfu/jack-mode.
-- eval x | "ted?" `isSuffixOf` x = privmsg (if x == "ted?" then "that would be an ecumenical matter" else "yes")
---  ^ so that version needs work still... a toggle features feature is highly desireable.  ... levels of stfu, interesting idea.  per command stfu'ness, interesting too.  combination... nice.
-- nice vapor

-- trying something (lets call it revisiting level 2, for 2.1)
--eval x | "test?" `isSuffixOf` x = privmsg (if x == "thetest?" then "that would be an ecumenical matter" else "yes") 

-- eval x | "test?" `isSuffixOf` x = privmsg (if "daskherb:" `isPrefixOf` x then "that would be an ecumenical matter" else "yes")  --works, as far as this goes.

-- -- ^ that, if works (ha!) is only one increment away from fully functioning trained jack, would put the ecumenical/yes in the "then" and leave the "else" blank, so it doesnt reply to questions (or even "*test?" questions) if it's not the one being asked.

-- repeating the working test, just as ? instead of test?
--disabling for 2020 uhohmegaderp cleanup
--eval x | "daskherb:" `isPrefixOf` x = privmsg (if "?" `isSuffixOf` x then "sure" else "so you say")  --works, as far as this goes. but gonna change the suffix"?" to infix"?"
eval x | "daskherb:" `isPrefixOf` x = privmsg (if "?" `isInfixOf` x then "sure" else ":)")  --works, as far as this goes.

-- trying level 2.2, where:   then "that would be an ecumenical matter"|"yes" else ""
-- if $name, if end="?" then either ecumenical or yes, else nada.
--eval x | "retest?" `isSuffixOf` x = privmsg (if "daskherb:" `isPrefixOf` x then "that would be an ecumenical matter"|"yes" else "")
--"" else "that would be an ecumenical matter"|"yes")  

-- level THREEs (development towards true random continues through other criteria).
--eval x | "?" `isSuffixOf` x = privmsg (runRandom (("yes"),("that would be an ecumenical matter.")))-- no way will i get this right first time.
--eval x | "?" `isSuffixOf` x = privmsg (runRandom (randR(("yes"),("that would be an ecumenical matter."))))-- no way will i get this right 2nd time.
--eval x | "?" `isSuffixOf` x = privmsg (randR ("yes","that would be an ecumenical matter."))
--ok, this one's using the list defined above.  ecumenical.  teehee.
--eval x | "ted?" `isSuffixOf` x = privmsg (random.choice(ecumenical))
--eval x | "ted?" `isSuffixOf` x = privmsg (randR(ecumenical))
---- ^ i will get there.  i'm close.
--eval x | "ted?" `isSuffixOf` x = privmsg (randR(ecumenical) x)
--eval x | "ted?" `isSuffixOf` x = privmsg (random.choice(ecumenical) x)
--eval x | "ted?" `isSuffixOf` x = privmsg (random.choice(ecumenical))
--eval x | "ted?" `isSuffixOf` x = privmsg (randR(ecumenical))
--eval x | "ted?" `isSuffixOf` x = privmsg (listo(rando)) -- halfway towards working it out then the insight slipped outta mind.
--eval x | "ted?" `isSuffixOf` x = privmsg (randomRs ('e', 'y'))-- 
--eval x | "ted?" `isSuffixOf` x = privmsg (randomRs ('e', 'y'))--
--eval "!gimmieanumber" = privmsg (randR ("1","2")
-- oh oh do it in an array!  ... make the list above an array!
--eval x | "ted?" `isSuffixOf` x = privmsg $ ecumenical
-- -- level 4, like level 0(?) use isInfixOf, yus.
--disabling for 2020 uhohmegaderp cleanup
eval x | "retest?" `isInfixOf` x = privmsg (if "daskherb:" `isPrefixOf` x then "that would be an ecumenical matter" else "yes")  --works, as far as this goes.
-- eventually i'll get that such that it's a full working fatherjackbot....
---- fatherjackbot:
--eval x | "?" `isInfixOf` x = privmsg (if "daskherb:" `isPrefixOf` x then "that would be an ecumenical matter" else "yes")  --works, as far as this goes.
-----commented out the full fatherjackbot line, since it would be annoying in a chan, answering every question with yes, unless asked directly then saying it would be an ecumenical matter.  the isInfixOf "?" could likely just as well be isSuffixOf.  that might reduce verbosity.
-----
--teehee
--eval x | "420" `isInfixOf` x = privmsg ("!toke Weedykins")
--eval x | "4:20" `isInfixOf` x = privmsg ("!toke all the lonely people")  -- now try pass to the chatter who issued the command.
--eval x | "!kyle" `isInfixOf` x = privmsg ("Listen, and understand. That terminator is out there. It can't be bargained with. It can't be reasoned with. It doesn't feel pity, or remorse, or fear. It absolutely won't stop until you're dead.")
eval x | " flo " `isInfixOf` x = privmsg ("!toke all who want to get motivated by toking some Flo")
eval x | "that's racist" `isInfixOf` x = privmsg ("https://www.youtube.com/watch?v=jPnP9IUMDLc")
--
eval x | "!themanfromearth" `isPrefixOf` x = privmsg ("http://ks392457.kimsufi.com/stuff/themanfromearth.mp4")
--
-- these are some basic sample commands for u to try out to make your own ones.
eval "hello" = privmsg "is there anybody in there?"
eval "evening gents" = privmsg "is that you drakken?"
eval "!notimeforcaution" = privmsg "what are you doing?  docking.  it's not possible.  no, it's necessary.   https://www.youtube.com/watch?v=a3lcGnMhvsA this is no time for caution. if i black out, you take the stick.  endurance is entering atmosphere.  she's got no heatsheild."
eval "this is no time for caution" = privmsg "https://www.youtube.com/watch?v=TV1767i8X4Q"
-- Jack Herer
eval x | "!jack" `isPrefixOf` x = privmsg "you dont know jack? https://jackherer.com/emperor-3/ https://www.youtube.com/watch?v=TaaupH6ZgUU :)"
eval "!jackherer" = privmsg "https://jackherer.com/emperor-3/  https://www.youtube.com/watch?v=TaaupH6ZgUU"
eval "!jack" = privmsg "https://jackherer.com/emperor-3/  https://www.youtube.com/watch?v=TaaupH6ZgUU"

eval "!testcommand" = privmsg "this is the test responce."

eval "!testcommand2" = privmsg "this is the test \t responce."
eval "!testcommand3" = privmsg "this is the test \0 responce."

eval x | "!russo" `isPrefixOf` x = privmsg "here's some: https://youtu.be/ht3getj1U0o"
-- eval x | "meep" `isInfixOf` x = privmsg "I detect a meep!"
eval "irie" = privmsg "bun bun babylon"
-- -- DONT DO THESE, THEY ARE BAD, N KILL OTHER BOTS/CLIENTS!
--eval x | "!arrowtest" `isPrefixOf` x = privmsg " ↑↓←→"
--eval x | "!moontest" `isPrefixOf` x = privmsg " " -- wont even compile
--eval x | "!mzfuzzybritchestest" `isPrefixOf` x = privmsg "෴෴෴෴෴"
eval x | "slow this bird down" `isInfixOf` x = privmsg " https://www.youtube.com/watch?v=wgbyID-Plqo "
--eval x | "!slowthisbirddown " `isPrefixOf` x = privmsg ("slow this " ++ (drop 18 x) ++ " down. https://www.youtube.com/watch?v=wgbyID-Plqo") -- -- test.  ~ and i lost salve, wat!  (update, no u didnt.  salve was never in daskherb.  that's weedykins who issues salve.)
eval x | "!slowthisbirddown " `isPrefixOf` x = privmsg ("slow this " ++ (drop 18 x) ++ " down. https://www.youtube.com/watch?v=UsOZ1NKInsE") -- -- test.  ~ and i lost salve, wat!  (update, no u didnt.  salve was never in daskherb.  that's weedykins who issues salve.)
eval x | "ultrahighdosepsilocybin2all" `isPrefixOf` x = privmsg " _ "
eval "!adereth" = privmsg "https://www.youtube.com/watch?v=uk3A41U0iO4 matt adereth's clojure.core/typing talk "
eval x | " dhmo" `isInfixOf` x = privmsg "dont fall for it.  it's using your chemistry ignorance and unconventional naming to obfuscate that it's just water!  it's just water!  dhmo = dihydrogenmonoxide = 2 hydrogen 1 oxygen = water.  dont ban it!  next they'll tell you cannabis/hemp is a demon called marijuana.  dont fall for lies trying to deprive you/us/all of essentials!"
eval x | "crazy bitch" `isInfixOf` x = privmsg "did someone say crazy bitch?  you mean her: https://www.youtube.com/embed/IgArgFsdkZk right?"
eval x | "human nature" `isInfixOf` x = privmsg "did someone say human nature?  you mean like: https://www.youtube.com/watch?v=EQnUFxoFqNY yes?"
eval x | "!booze" `isPrefixOf` x = privmsg "you must be a robot from the future futurama told us about.  do drink up."
--eval "!bong" = privmsg "gurgle gurgle gurgle"
eval x | "!longbong" `isPrefixOf` x = privmsg "click, click-fwoomf, gurgle gurgle gurgle gurgle gurgle gurgle-gurgle-gurgle . . . ahhhhhhhhhhh.  :)"
eval x | "!kylebong" `isPrefixOf` x = privmsg "Listen!  And Understand.  That Terminator is out there. It cant be bargained with.  It cant be reasoned with.  It does not feel pity, or remorse, or fear. And it absolutely will not stop, EVER, until you are click-click-fwoom glrglglrglglrglrlgrlglrglrhoooh dead"
eval x | "!ragebong" `isPrefixOf` x = privmsg "rage against the pain!"
eval x | "!mendbong" `isPrefixOf` x = privmsg "mendwards!  gurgleglurgleblurglegurgle!"
eval x | "!mendwardsbong" `isPrefixOf` x = privmsg "mendwards!  gurgleglurgleblurglegurgle!"
eval x | "!kiefbong" `isPrefixOf` x = privmsg "light er up and getter done doggy.              I am fucking high."
eval x | "!christmasbong" `isPrefixOf` x = privmsg "tis the season for kaneh bosm!  get annointed, become christ'ened.  girglgluglgriglbliglblurgleglugglug."
eval x | "!choonsbong" `isPrefixOf` x = privmsg "TUNE!  knees up, hands up, fly!  boppin along.  gurgle plurgle blurgle gurgle."
eval x | "!drop" `isPrefixOf` x = privmsg "drop some terpenes + etc and be fine :)"
--eval x | "!bong" `isPrefixOf` x = privmsg "gurgle gurgle gurgle"
eval x | "!bong" `isPrefixOf` x = privmsg "blurgle gurgle blurble"
--eval "!bongsmile" = privmsg ":פ" -- just to test that character that looked like a gargling smile
--eval x | "!vape" `isPrefixOf` x = privmsg "We can vape if we want to, We can leaf your friends' good minds, 'Cause your friends don't vape And if they don't vape, We'll get your friends so high!"
eval x | "!vape" `isPrefixOf` x = privmsg "We can vape if we want to, We can leaf your friends' good minds, 'Cause your friends want vape And if they want vape, We'll get your friends so high!"
eval x | "!edible" `isPrefixOf` x = privmsg "om nom nom.   wait wait wait.   .... spaaaaaaaace."
-- eval "!megavape" `isPrefixOf` x = privmsg "zomfg"
eval x | "!megavape" `isPrefixOf` x = privmsg "zomg"
--eval "!1hitta" `isPrefixOf` x = privmsg "efficient"
eval x | "!1hitter" `isPrefixOf` x = privmsg "efficient"
--eval "!1hitter" `isPrefixOf` x = privmsg "efficient"
eval "!blunt" = privmsg "light er up take a puff"
eval x | "!blunt" `isPrefixOf` x = privmsg "Suck down that fat blunt"
eval "!spliff" = privmsg "now it's come to that time of the night, for spliff politics, when everybody knows who's got a spliff, and which direction it's going."
eval x | "!spliff" `isPrefixOf` x = privmsg "have a toke on this tasty spliff."
eval "!spliffpolitics" = privmsg "now it's come to that time of the night, for spliff politics, when everybody knows who's got a spliff, and which direction it's going.  https://youtu.be/bfSXjwmvA7s "
eval x | "!spliff" `isPrefixOf` x = privmsg "now it's come to that time of the night, for spliff politics, when everybody knows who's got a spliff, and which direction it's going.  https://youtu.be/bfSXjwmvA7s "
eval x | "!spacebong" `isPrefixOf` x = privmsg "roads?  where we are going, we do not need ... roads.   gurgle gurgle gurgle"
-- making bongs able to have more said after them.
eval x | "!churchbong" `isPrefixOf` x = privmsg (if "420" `isSuffixOf` x then "happy 420.  ~ gurgle gurgle gurgle" else "ommmmmmmm.   we are gathered here today, to partake of the holy sacrament, the holy herb.  congregation, lift and light your bongs.  let us get high.  :) gurgle gurgle gurgle")
eval x | "!songbong" `isPrefixOf` x = privmsg "gurgle gurgle gurgle - https://soffmimuhod.bandcamp.com/track/havabong" -- old classic.
eval x | "!dunebong" `isPrefixOf` x = privmsg "It is by will alone I set my mind in motion. It is by the smoke of cannabis that thoughts acquire depth, the eyes acquire blood, the blood becomes a warning. It is by will alone I set my mind in motion.  ~  gurgle gurgle gurgle  ~ " --https://www.youtube.com/watch?v=P5zB-KHUAcU " -- will want that without the url eventualy too.  --thnx for dunebong, dugz (we think it was dugz who came up with it... fairly sure... ish).
eval x | "!dugzbong" `isPrefixOf` x = privmsg "It is by will alone I set my mind in motion. It is by the smoke of cannabis that thoughts acquire depth, the eyes acquire blood, the blood becomes a warning. It is by will alone I set my mind in motion.  ~  gurgle gurgle gurgle  ~ " --https://www.youtube.com/watch?v=P5zB-KHUAcU " -- will want that without the url eventualy too.
eval x | "!spicebong" `isPrefixOf` x = privmsg "It is by will alone I set my mind in motion. It is by the smoke of cannabis that thoughts acquire depth, the eyes acquire blood, the blood becomes a warning. It is by will alone I set my mind in motion.  ~  gurgle gurgle gurgle ~"
eval x | "!bomg" `isPrefixOf` x = privmsg "gurgle gurgle gurgle - https://soffmimuhod.bandcamp.com/track/havabong - (you typo'd bong again.  but that's ok.  i dont want to deny you a bong rip."
eval x | "!rig" `isPrefixOf` x = privmsg "get that perfect temp and..... fwwooooommm!  ~  slursslursrurslurslursrulsursurs"
eval x | "!peaches" `isPrefixOf` x = privmsg "toke the pain away.  toke the pain away.  tokin on cannabis, like you wanted tea.   toke the pain away.  toke the pain away."
--eval "!beer" = privmsg "fine, here, have your beer and be damned."-- this was only here for whimsy.  daskHERB doesnt dish out beer...  or....
eval "!beer" = privmsg "glug glug glug.  https://duckduckgo.com/?q=cannabis+beer chugging something good, for good health"
eval "!stars" = privmsg " see !benrich and !bennetthart"
eval "!benrich" = privmsg "  “We already have the means to travel among the stars, but these technologies are locked up in black projects and it would take an act of God to ever get them out to benefit humanity… anything you can imagine we already know how to do.” — Ben Rich, former Head of the Lockheed Skunk Works "
eval "!bennetthart" = privmsg " “It is easier for us to pay a private contractor to re-invent something so it will come out at a lower classification level, than to try to declassify it.” – Bennett Hart, then Deputy Director of the National Reconnaissance Organization "
--eval "!test and test" = privmsg " see "
--eval "!" = privmsg ""
eval "!chillum" = privmsg "light it up!"
eval x | "!chillum" `isPrefixOf` x = privmsg "praise jah"
eval x | "!havabong" `isPrefixOf` x = privmsg "https://soffmimuhod.bandcamp.com/track/havabong"
eval x | "!ominator" `isPrefixOf` x = privmsg "https://soffmimuhod.bandcamp.com/track/ominator-preview2"
-- next make bongs passable.   ... maybe have a single hitter output when not passing, and a different output when passing.   if just bong, solo bong, if bong name, pass bong, if bong not-name, solo bong.

-- -- !toke commands are for when weedykins is offline.  ;)
-- ---- eval "!toke" = privmsg "Puff! Puff! Pass! ^__^ "
--eval x | "!toke" `isPrefixOf` x = privmsg "Puff! Puff! Pass! ^__^ "
--eval x | "!pass " `isPrefixOf` x = privmsg ("Puff Puff Pass, " ++ (drop 5 x) ++ "! You're fucking up the rotation.") -- test remake of weedykins' !toke (see !pass)
-- ----eval x | "!toke " `isPrefixOf` x = privmsg ("Puff Puff Pass, to" ++ (drop 5 x) ++ "! ^__^") -- identical remake of weedykins' !toke (see !pass)
eval "!toke daskherb" = privmsg "dont pass to me.  i dont have the lungs for it."
eval "!toke daskherb " = privmsg "dont pass to me.  i dont have the lungs for it."
eval "!walk" = privmsg "take your plants for a tour https://www.youtube.com/watch?v=iD9VI2rnc4g put a smile on your face."
eval "!dank" = privmsg "take your plants for a tour https://www.youtube.com/watch?v=iD9VI2rnc4g put a smile on your face."
eval "!session" = privmsg "https://www.youtube.com/watch?v=iD9VI2rnc4g"
eval "!massage" = privmsg "YEAH!  move that lymphatic goop!  :)  soften that muscle tension.  soften the body, relax the mind.  self massage is gooooooood.  take a massage-break.  you've earned it.  and it will help you make the world a better place."
eval x | "!tokough" `isPrefixOf` x = privmsg "*cough* *cough* pass"
-- eval "!tokough" = privmsg "*cough* *cough* pass"
eval x | "!remainindoors" `isPrefixOf` x = privmsg "REMAIN INDOORS https://www.youtube.com/watch?v=X888i7hzvP0"
eval x | "!lockdown" `isPrefixOf` x = privmsg "REMAIN INDOORS https://www.youtube.com/watch?v=wnd1jKcfBRE"
eval x | "!mitchellwebb" `isPrefixOf` x = privmsg "REMAIN INDOORS https://www.youtube.com/watch?v=22mt0cVyW5c"
eval x | "!quiz" `isPrefixOf` x = privmsg "REMAIN INDOORS https://www.youtube.com/watch?v=22mt0cVyW5c"
eval x | "!theevent" `isPrefixOf` x = privmsg "REMAIN INDOORS https://www.youtube.com/watch?v=22mt0cVyW5c"
--eval "!enema" = privmsg "coffee or cannabis?"
--eval "!pee" = privmsg "have a glorious pee pee."
--eval "!poop" = privmsg "may all poop be smooth and anandamide inducing."
eval "!coffee" = privmsg "colon or esophagus?  detox or drug?"
-- coffee please
--eval "coffee please" = privmsg "ok, here's 500ml yirgacheffe coffee, cool to under a 4second sting, quardouple strength, hempseed oil lubed for insertion.  hold it for 9-12 minutes, if you can. rub your belly anti-clockwise.  dont hesitate to get to the toilet if you feel the need.  super charging liver!  to good health and wellbeing, yay!  stay hydrated and remineralised."
--eval x | "colon please" `isPrefixOf` x = privmsg "ok, here's yirgacheffe 500ml, cool to under a 4second sting, quardouple strength, hempseed oil lubed for insertion.  hold it for 9-12 minutes, if you can. rub your belly anti-clockwise.  dont hesitate to get to the toilet if you feel the need.  super charging liver!  to good health and wellbeing, yay!  stay hydrated and remineralised."
--eval "cannabis please" = privmsg "cannabis!? up the bum!?  ;D"
eval x | "esophagus" `isPrefixOf` x = privmsg "https://66.media.tumblr.com/00afe13500a385c70b390f3bf319b993/tumblr_ot1bhaNLAJ1s9a9yjo1_400.gif"
-- back by popular demand (no enema tho)
eval "!coffeemug" = privmsg "https://66.media.tumblr.com/00afe13500a385c70b390f3bf319b993/tumblr_ot1bhaNLAJ1s9a9yjo1_400.gif"
eval "!detox" = privmsg "coffee enema, lymph massage, bouncing rebound, juice cleanse, more hydration, sauna, ... what else you got?"
eval "detox please" = privmsg "coffee enema, lymph massage, bouncing rebound, juice cleanse, ... what else you got?"
--eval x | "just google it" `isPrefixOf` x = "https://www.greenmedinfo.com/blog/how-google-uses-mind-control-tactics-promote-pro-vaccine-industry-propaganda  that google?  you want me to use them to websearch?   maybe i'll try duckduckgo instead, or searx, or even a startpage or a ixquick, or, hell even yahoo or some shit.  just google it  HA!  wake up, sucker.  they got you asleep."
eval "!brownie" = privmsg "om nom nom ... om nom nom.  ... ... om nom nom nom nom nom nom nom."
eval x | "!munch" `isPrefixOf` x = privmsg "om nom nom"
eval "!munch" = privmsg "with jam in.  :)  with jam in.  with jam in.  yeah we hope you like jam in too.   with jam in.  ;D  holding my sandwich."
eval "!nom" = privmsg "https://jackherer.com/emperor-3/chapter-8/ through history 50%-80% of food for humanity has been cannabis hemp."
eval "!walkmore" = privmsg "https://www.youtube.com/watch?v=iD9VI2rnc4g"
eval "!cbd" = privmsg "https://www.youtube.com/watch?v=3bZb10ZxpBk"
eval "!cistine" = privmsg "http://ks392457.kimsufi.com/stuff/DigitCistine.jpg"
eval "!paulflynn" = privmsg "https://www.youtube.com/watch?v=RJ0bwDe8o2M"
eval "!amomentofclarity" = privmsg "https://www.youtube.com/watch?v=UVj8jc_x7J4"
eval "!spray" = privmsg "spritz-spritz the phyto-cannabinoids swimming under the tongue ....   mmmmmmmm :)"
eval "!tincture" = privmsg "drip drip drip ....    mmmmmmm :)"
-- took out !roll for when weedykins is doing !roll too.
--eval "!roll" = privmsg "rolllllllll another one... "
--eval "!wake&bake" = privmsg "i toked 2 joints in the morning, and then i toked 2 more."
eval x | "!wake&bake" `isPrefixOf` x = privmsg "set up the day, the right way. :D"
eval x | "!wake-n-bake" `isPrefixOf` x = privmsg "set up the day, the right way. :3"
eval x | "!wake" `isPrefixOf` x = privmsg "set up the day, the right way. :)  wake and bake."
eval x | "!jbreak" `isPrefixOf` x = privmsg "Tonight there's gonna be a J break,  Somewhere in this chan."
eval x | "!stoned" `isPrefixOf` x = privmsg "  ll&p  \\\\//_  --__--  _\\\\//  p&ll "
--eval x | "!stoned" `isPrefixOf` x = privmsg "Melllllooooowwwwwwww  http://www.youtube.com/watch?v=4a-apSofamw  "
--eval x | "!stoned" `isPrefixOf` x = privmsg "or just pebbled?  ... (please suggest a better response for the !stoned command)"
--eval "!daskeb" = privmsg "hello, i am daskeb, digit's haskell bot.  of course, i'm just a basic starter template.  you might want to look up http://www.haskell.org/haskellwiki/Roll_your_own_IRC_bot just for starters.  i came from half of that. i now have my own web presence at http://wastedartist.com/scripts/daskeb/daskeb.html"
eval "!om" = privmsg " https://www.youtube.com/watch?v=UVj8jc_x7J4 " 
eval "!didge" = privmsg "BWAWWUWUWUWOUWOUWOUYOIYIOWOAWOOWAYAYAYYIYIYIWUWUWAWUWOAWAWU"
eval "!wank" = privmsg "fapfapfapfapfap"
eval "!dmt" = privmsg "https://www.youtube.com/watch?v=xORdSgCbjyU"
eval "!socrates" = privmsg "socrates is reported to have said 'all i know is i know nothing', to which i add 'and sometimes i forget even that much'"
eval "!about" = privmsg "hello, i am (based on) daskeb, digit's haskell bot, just a basic starter template.  you might want to look up http://www.haskell.org/haskellwiki/Roll_your_own_IRC_bot just for starters.  it originally came from half of that."
eval "!help" = privmsg "you'll get no help from me.  i'm mystereous like that.   ... i also cant spell."
eval "!roids" = privmsg "beefcaaaaake!"
--eval x | "whistle" `isInfixOf` x = privmsg "https://www.youtube.com/watch?v=uc4JxNDCy0c" -- pickle blow 
eval "!rar!" = privmsg "https://66.media.tumblr.com/ed523645ec41ca24826cfb9ca2a7d44a/tumblr_pq3e6hN5G91ukxxj7o1_400.gifv"
eval "!bruv" = privmsg "nice one bruv.  https://www.youtube.com/watch?v=qksndNDMDOw # bruvaaaaaa"
--
eval x | "!squatch" `isPrefixOf` x = privmsg "https://www.youtube.com/watch?v=P5zB-KHUAcU" --https://www.youtube.com/watch?v=P5zB-KHUAcU " -- will want that without the url eventualy too.
--
eval "!meditate" = privmsg "http://the9gag.com/images/pictuers/cool_morning.jpg"
eval "!pain" = privmsg "toke the pain away!"
eval "!kratom" = privmsg "i don't ever take actual opiods"
eval "!cult" = privmsg "repeat the mantra: 3,4,5,6,-tetrahydro-7-hydroxy-alpha-alpha-2-trimethyl-9-n-propyl-2,6-methano-2H-1-benzoxocin-5-methanol 420 times.   can just manage to say it once a breath.  and then... you'll have done that."
eval "!cats" = privmsg "https://http.cat/420"
eval "!moth" = privmsg "https://www.youtube.com/watch?v=JG6x4MHdTWM"
-- weather dev
-- -- so, folks can punch in their lon/lat, n it'd use that, and get the "now" time from the timestamp...   yep, this is my project. 
eval "!weather" = privmsg "dude.  i cant tell you the weather yet.  that feature's only just been conceived of.  still not even in real development yet.  go look at a map: https://earth.nullschool.net "
eval x | "!weather" `isPrefixOf` x = privmsg "still to be developed."
eval x | "!bucky" `isPrefixOf` x = privmsg "one in ten thousand of us can make a technological breakthrough capable of supporting all the rest. The youth of today are absolutely right in recognizing this nonsense of earning a living.  -- buckminster fuller    (#9 on this bucky quotes list: https://theunboundedspirit.com/16-of-the-best-buckminster-fuller-quotes/ )"
eval x | "daskherb: tell me a secret " `isPrefixOf` x = privmsg "daskherb: tell me a secret :: Digit, myn creator, was conceived on (or near) 4:20 1981, 19 years before...  shsh, no, you havent heard that.  dont tell anyone.  shsh.  39 years ago"
--reasons against shites
-- have not got this on all the time to prevent pissing people off.   :/  pity they'd rather burry their head's in the meat grinder, than listen to a health n safety lecture about meat grinders.
-- dont be a dick about em.  :3
--eval x | "amazon.com" `isInfixOf` x = privmsg "consider https://www.stallman.org/amazon.html https://www.youtube.com/watch?v=AQeGBHxIyHw https://duckduckgo.com/?q=boycott+amazon https://i.giphy.com/media/LyKsWcZiTxSrS/200.gif https://www.youtube.com/watch?v=LpG6jzawQnE"
eval x | "!amazon" `isPrefixOf` x = privmsg "consider https://www.stallman.org/amazon.html https://www.youtube.com/watch?v=AQeGBHxIyHw https://duckduckgo.com/?q=boycott+amazon https://i.giphy.com/media/LyKsWcZiTxSrS/200.gif https://www.youtube.com/watch?v=LpG6jzawQnE"
-- dont be a dick about em.  :3
-- eval x | "twitter.com" `isInfixOf` x = privmsg "https://www.stallman.org/twitter.html"
eval x | "!twitter.com" `isPrefixOf` x = privmsg "https://www.stallman.org/twitter.html"
eval x | "!tea" `isPrefixOf` x = privmsg "https://satwcomic.com/hot-brew"
eval x | "!activismislife" `isPrefixOf` x = privmsg "see commands !activism !life"
eval x | "!activism" `isPrefixOf` x = privmsg "raise awareness about the truth about cannabis to empower people to grow their own."
eval x | "!life" `isPrefixOf` x = privmsg "raise awareness about the truth about cannabis to empower people to grow their own."
eval x | "!snoop" `isPrefixOf` x = privmsg "https://www.youtube.com/watch?v=wi7Mblv-S1E"
eval x | "!nark" `isPrefixOf` x = privmsg "everybody look around and see if you can spot the narks.  . . .   they're the ones dressed as hippies."
eval x | "!narc" `isPrefixOf` x = privmsg "everybody look around and see if you can spot the narks.  . . .   they're the ones dressed as hippies."
eval x | "!spacesnoop" `isPrefixOf` x = privmsg "https://www.youtube.com/watch?v=PT14rcBHV8M"
eval     _                     = return () -- ignore everything else
 
-- Send a privmsg to the current chan + server
privmsg :: String -> Net ()
privmsg s = write "PRIVMSG" (chan ++ " :" ++ s)
 
-- Send a message out to the server we're currently connected to
write :: String -> String -> Net ()
write s t = do
    h <- asks socket
    io $ hPrintf h "%s %s\r\n" s t
    io $ printf    "> %s %s\n" s t
 
-- Convenience.
io :: IO a -> Net a
io = liftIO
